<template>
  <section class="status">
    <MyHeader :isCloseShow="isCloseShow"></MyHeader>
    <div v-if="status.wait == type" class="status-content wait">
      <img src="../assets/img/bc_wait.png" alt="等待中">
      <p>您的申请已经提交
        喝杯茶等会呗~~</p>
      <button @click="routerToHome">回到首页</button>
    </div>
    <div v-if="status.success == type" class="status-content success">
      <img src="../assets/img/bc_success.png" alt="成功">
      <p>恭喜你，Token已经{{title}}成功！</p>
      <button @click="routerToRecord">查看详情</button>
    </div>
    <div v-if="status.fail == type" class="status-content fail">
      <img src="../assets/img/bc_fail.png" alt="失败">
      <p>抱歉，Token发布失败！</p>
      <span>{{ applyInfo.msg }}</span>
      <button @click="routerToHome">重新发行</button>
    </div>
  </section>
</template>

<script lang="ts">
    import {Component, Vue} from 'vue-property-decorator';
    import myStatus from "@/types/status";
    import MyHeader from '@/components/MyHeader.vue';
    import {getApplyDetail} from '@/api/api';
    import {ConfirmForm} from '@/types/form'

    @Component({
        components: {
            MyHeader
        },
    })
    export default class Status extends Vue {
        private status: any = myStatus
        private type: any = null;
        private title: any = "";
        private isCloseShow: Boolean = false;
        private getApplyDetail = getApplyDetail;
        private applyInfo: any = {};
        private ConfirmForm: any = new ConfirmForm();

        beforeMount() {
            this.type = this.$route.query.type;
            this.title = this.$route.query.title;
            let id = String(this.$route.query.id);
            //查找详情 设置手续费
            this.getApplyDetail({id: id}).then((res: any) => {
                this.applyInfo = Object.assign(this.ConfirmForm, res);
                this.applyInfo.issue_charge = res.charge
                this.applyInfo.msg = res.msg
            })
            this.isCloseShow = this.type == myStatus.wait
        }

        routerToRecord() {
            this.$router.push({
                path: '/record-detail',
                query: {id: this.applyInfo.id}
            })
        }

        routerToRecordList() {
            this.$router.push({path: "/record"});
        }

        routerToHome() {
            this.applyInfo.resetTotal()
            this.$router.push({
                path: '/home'
            })
        }

    }
</script>

<style scoped lang="scss">
  .status {
    background-color: #333649;
    height: 100vh;
    position: relative;

    .header {
      position: relative;
      z-index: 10;
    }

    &-content {
      position: absolute;
      top: -30px;
      bottom: 0;
      left: 0;
      right: 0;
      margin: auto;
      z-index: 9;

      display: flex;
      flex-direction: column;
      justify-content: center;
      align-items: center;

      p {
        font-size: 18px;
      }

      img {
        width: 163px;
        height: 144px;
      }

      button {
        width: 100px;
        height: 34px;
        border-radius: 29px;
        background-color: #5E6377;
      }
    }
  }

  .success {
    p {
      margin-top: 60px;
    }

    button {
      margin-top: 24px;
    }
  }

  .fail {
    p {
      margin-top: 20px;
    }

    span {
      width: 50%;
      word-wrap: break-word;
      margin-top: 5px;
      color: #F29049;
    }

    button {
      margin-top: 24px;
    }
  }

  .wait {
    p {
      width: 150px;
      margin-top: 50px;
    }

    button {
      margin-top: 24px;
    }
  }
</style>
